<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<base href="<%=basePath%>">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>文档管理</title>
		<link rel="stylesheet" type="text/css" href="../css/base.css">
		
<script language="javascript" src="js/jquery-1.7.2.min.js"></script>
<script language="javascript" src="js/jquery-ui-1.8.22.custom.min.js"></script>
<script language="javascript" src="js/common.js?v=1"></script>
<script type="text/JavaScript">
// 页面初始化加载的时候调用的方法
$(document).ready(function(){
	// 给添加广告位按钮绑定一个单击事件
  $("#addBtn").bind("click",function(){
    document.searchAdvertAddressForm.action = "jumpToAdeverAddress.action";
		document.searchAdvertAddressForm.submit();
  });
  
  // 给搜索按钮绑定一个单击事件
  $("#searchBtn").bind("click",function(){
  	alert(2);
    document.searchAdvertAddressForm.action = "advertAddressAct!searchAdvertAddress.action";
		document.searchAdvertAddressForm.submit();
  });
  
   // 给搜索按钮绑定一个单击事件
  $("#delBtn").bind("click",function(){
  	alert(2);
    document.searchAdvertAddressForm.action = "advertAddressAct!delAdvertAddress.action";
		document.searchAdvertAddressForm.submit();
  });
  
});

function initUptAdvertAddress(id){
	document.searchAdvertAddressForm.action = "advertAddressAct!initUptAdvertAddress.action?advertAddressVo.id=" + id;
	document.searchAdvertAddressForm.submit();
} 

//翻页效果
function chgPage(btnFlg){
  var curPage = parseInt($("#curPage").val());
  var totalPages = parseInt($("#totalPages").val());
  if(btnFlg == 1){
	  if(curPage==1){
	    alert("已经是首页");
	    return;
	  }
	  // 设置当前页为第一页
	  $("#curPage").val(1);
	} else if(btnFlg == 2){
	  if(curPage==1){
	    alert("已经是第一页");
	    return;
	  }
	  // 设置当前页为当前页-1
	  $("#curPage").val(curPage - 1);
	} else if(btnFlg == 3){
	  if(curPage==totalPages){
	    alert("已经是最后一页");
	    return;
	  }
	  // 设置当前页为当前页+1
	  $("#curPage").val(curPage + 1);
  } else if(btnFlg == 4){
  		if(curPage==totalPages){
	    alert("已经是末页");
	    return;
	  }
	  // 设置当前页为最后一页
	  $("#curPage").val(totalPages);
  } else if(btnFlg == 5){
  	var chgPageNum = parseInt($("#chgPageNum").val());
  	if(chgPageNum<1 || chgPageNum>totalPages){
  	  alert("您输入的页码不存在，请重新输入");
	    return;
  	} else if(curPage==chgPageNum){
	    alert("当前页已经是您所要跳转的页面了");
	    return;
	  }
	  // 设置当前页为最后一页
	  $("#curPage").val(chgPageNum);
  }
  document.searchAdvertAddressForm.action = "advertAddressAct!searchAdvertAddress.action";
	document.searchAdvertAddressForm.submit();
}
</script>

	</head>
	<body leftmargin="8" topmargin="8" background='images/allbg.gif'>
	<s:form name="searchAdvertAddressForm" id="searchAdvertAddressForm" method="post" action="">
	<s:hidden name="advertAddressVoQry.totalPages" id="totalPages" value="%{advertAddressVoQry.totalPages}" />
	<s:hidden name="advertAddressVoQry.curPage" id="curPage" value="%{advertAddressVoQry.curPage}" />
		<!--  快速转换位置按钮  -->
		<table width="98%" border="0" cellpadding="0" cellspacing="1"
			bgcolor="#D1DDAA" align="center">
			<tr>
				<td height="26" background="images/newlinebg3.gif">
					<table width="98%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td align="center">
								<input type='button' name="addBtn" id="addBtn" value='添加广告位' />
								<input type='button' name="delBtn" id="delBtn" value='删除广告位' />
								<input type='button' onClick="location='';" value='稿件审核' />
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>

		<!--  内容列表   -->
			<table width="98%" border="0" cellpadding="2" cellspacing="1"
				bgcolor="#D1DDAA" align="center" style="margin-top: 8px">
				<tr bgcolor="#E7E7E7">
					<td height="24" colspan="10" align="center"
						background="images/tbg.gif">
						&nbsp;广告位信息列表&nbsp;
					</td>
				</tr>
				<tr align="center" bgcolor="#FAFAF1" height="22">
					<td width="6%" align="center">
						编号
					</td>
					<td width="4%" align="center">
						选择
					</td>
					<td width="14%" align="center">
						广告位名称
					</td>
					<td width="10%" align="center">
						广告位大小
					</td>
					<td width="10%" align="center">
						默认广告类型
					</td>
					<td width="8%" align="center">
						默认广告地址
					</td>
					<td width="20%" align="center">
						备注
					</td>
					<td width="10%" align="center">
						操作
					</td>
				</tr>							
				<s:iterator value="advertAddressVoList" status="nowIndex">
				<tr align='center' bgcolor="#FFFFFF"
					onMouseMove="javascript:this.bgColor='#FCFDEE';"
					onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
					<td>
						${(nowIndex.index+1)+(advertAddressVoQry.curPage-1)*advertAddressVoQry.numPerPage}
					</td>
					<td>               
						<s:checkbox name="selectId" fieldValue="%{id}" theme="simple" />
					</td>
					<td align="left">
						<s:property value="%{advertName}" />---id=<s:property value="%{id}" />
					</td>
					<td align="center">
						<s:property value="%{width}" />*<s:property value="%{height}" />
					</td>
					<td align="center">
						<s:property value="%{defTypeValue}" />
					</td>
					<td>
						<s:property value="%{defPath}" /> 
						<!-- <img alt="图片" src="UploadFile/<s:property value='%{defPath}' />">-->
					</td>
					<td>
						<s:property value="%{notes}" />
					</td>				
					<td>
						<a href="javascript:initUptAdvertAddress(<s:property value='%{id}' />)">编辑</a> |
						<a href="">预览</a>
					</td>
				</tr>
				</s:iterator>
				<tr bgcolor="#FAFAF1">
					<td height="28" colspan="10">
						&nbsp;
						<a href="javascript:selAll('selectId')" class="coolbg">全选</a>
						<a href="javascript:unSelectAll('selectId')" class="coolbg">反选</a>
						<a href="javascript:cancelAll('selectId')" class="coolbg">取消</a>
						<a href="javascript:initUptAdvertAddress(<s:property value='%{id}' />)" class="coolbg">&nbsp;更新&nbsp;</a>
						<a href="javascript:checkArc(0)" class="coolbg">&nbsp;审核&nbsp;</a>
						<a href="javascript:adArc(0)" class="coolbg">&nbsp;推荐&nbsp;</a>
						<a href="javascript:moveArc(0)" class="coolbg">&nbsp;移动&nbsp;</a>
						<a href="javascript:delArc(0)" class="coolbg">&nbsp;删除&nbsp;</a>
					</td>
				</tr>
				<tr align="right" bgcolor="#EEF4EA">
					<td height="36" colspan="10" align="center">
						<!--翻页代码 -->
						<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="right-font08">
	            <tr>
	              <td width="50%">共 <span class="right-text09"><s:property value="%{advertAddressVoQry.totalPages}" /></span> 页 | 第 <span class="right-text09"><s:property value="%{advertAddressVoQry.curPage}" /></span> 页</td>
	              <td width="49%" align="right">[<a href="javascript:chgPage(1);" class="right-font08">首页</a> | <a href="javascript:chgPage(2);" class="right-font08">上一页</a> | <a href="javascript:chgPage(3);" class="right-font08">下一页</a> | <a href="javascript:chgPage(4);" class="right-font08">末页</a>] 转至：</td>
	              <td width="1%">
	                <table width="20" border="0" cellspacing="0" cellpadding="0">
	                  <tr>
	                    <td width="1%"><input name="chgPageNum" id="chgPageNum" type="text" class="right-textfield03" size="1" /></td>
	                    <td width="87%"><input name="Submit23222" type="button" onclick="javascript:chgPage(5);" class="right-button06" value="跳转" />
	                    </td>
	                  </tr>
	                </table>
	              </td>
	            </tr>
	        	</table>
					</td>
				</tr>
			</table>
		<!--  搜索表单  -->
			<input type='hidden' name='dopost' value='' />
			<table width='98%' border='0' cellpadding='1' cellspacing='1'
				bgcolor='#CBD8AC' align="center" style="margin-top: 8px">
				<tr bgcolor='#EEF4EA'>
					<td background='images/wbg.gif' align='center'>
						<table border='0' cellpadding='0' cellspacing='0'>
							<tr>
								<td width='90' align='center'>
									搜索条件：
								</td>
								<td width='160'>	
									<s:action name="advertTypeAct!findAdvertType" id="advertDefTypeAct"/>
									<s:select name="advertAddressVoQry.defType" cssStyle="width:100;height:20" listKey="code" 
										listValue="value" 	list="#advertDefTypeAct.advertTypeVoList" theme="simple" />
								</td>
								<td width='100'>
									广告位名称：
								</td>
								<td width='200'>
									<s:textfield name="advertAddressVoQry.advertName" theme="simple" />								
								</td>
								<td width='110'>
									<select name='orderby' style='width: 80px'>
										<option value='id'>
											排序...
										</option>
										<option value='pubdate'>
											发布时间
										</option>
									</select>
								</td>
								<td>
									<input name="searchBtn" type="button" id="searchBtn" value="搜索">
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</s:form>
	</body>
</html>